
<!-- 确认支付结果等待页面  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" 
                                                  prefix="fn" %>
<%@ include file="/pages/common/taglibs.jsp"%>
<!--[if IE 6]><div id="ie6" class="ie"><![endif]-->
<!--[if IE 7]><div id="ie7" class="ie"><![endif]-->
<%-- <tiles:insertAttribute name="header" />
	<div class="main fix">
		<tiles:insertAttribute name="content" />
	</div>
	<tiles:insertAttribute name="footer" /> --%>
<!--[if lte IE 7]></div><![endif]-->

<script type="text/javascript">
  var ctx = '${ctx}';
  var result = '';
  var orderId = '${orderId}';
  var loop =0;
  var time;
  
  ///跳转到 展示页面
  function notify(){
      window.location.href=ctx + "/jumpUrl_expay.do?orderId=${orderId}";
  }
  
  function loopNotify(){
      $.ajax({
          url:ctx+"/expay/getOrderResult.do?"+(new Date()).getTime(),
          async:false,
          type:"GET",
          //dataType:"JSON",
          data:{orderId:orderId}
      }).done(function(data){
          result = data;
      });
  }
  
  function timedCount(){
	  $('#sec').text(20 - loop * 2);
	  
      loop=loop+1;
      time = setTimeout("timedCount()", 2000);
      if (result == '1'){
          clearTimeout(time);
          notify();
      } else if (result == "2") {
    	  clearTimeout(time);
    	  $('#tips').text("通知结果失败！orderID=" + orderId);
      } else if(loop > 10){//超时
          clearTimeout(time);
          ///window.location.href=ctx;
          //本页面 提示超时
          $('#tips').text("处理超时！");
      }else{
          loopNotify();
      }
  }
  
  $(function() {
      if (result == '1') {
          notify();
      } else {
          timedCount();
      }
  });
  
</script>	
	 <span id="tips" style="font-size: 30px">付款处理中，请稍后.... 
	 </span>
	 <span>
	   <img src="${ctx }/image/loading.gif" alt="" /> <span id="sec"></span>s
	 </span>

